package com.daoImpl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.dao.UserDao;
import com.domain.User;

import dao.base.BaseDaoImpl;


@Repository(value="userDao")
public class UserDaoImpl extends BaseDaoImpl<User> implements UserDao {

	@Override
	public User findUserByUsername(String username) {
		DetachedCriteria userDC = DetachedCriteria.forClass(User.class);
		userDC.add(Restrictions.eq("username", username));
		List<User> list = (List<User>) this.getHibernateTemplate().findByCriteria(userDC);
		if(list!=null && list.size()>0){
			return list.get(0);
		}else{
			return null;
		}
	}


	/*public List<User> findUser(String query, String username, String password) {
		
		return (List<User>) this.getHibernateTemplate().find(query,username,password);
	}*/
	
}
